package com.zenithsun.news.newsinfo.service;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.syzg.common.service.BaseService;
import com.syzg.core.exception.ServiceException;
import com.syzg.core.page.PageResult;
import com.zenithsun.common.bean.OutMessage;
import com.zenithsun.news.newsinfo.model.Newsinfo;
import com.zenithsun.news.newsinfo.model.Newsdetailinfo;
import com.zenithsun.news.specialnews.model.Specialnews;

public interface NewsinfoService extends BaseService<Newsinfo> {
	
	/**
	 * 剪切图片
	 * 2016-7-11 15:54:02
	 * @param newId
	 * @param width
	 * @param height
	 * @param px_1
	 * @param py_1
	 * @param px_2
	 * @param py_2
	 * @return
	 * @throws Exception
	 */
	public OutMessage cutCover(String newId, int width, int height, int px_1, int py_1, int px_2, int py_2, HttpServletRequest request) throws Exception;
	
	/**
	 * 上传图片作为封面
	 * @param newId
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public OutMessage uploadCover(String newId, HttpServletRequest request) throws Exception;
	
	public void delNewsinfoDetail(String[] ids, HttpServletRequest request) throws ServiceException;
	
	public void delNewsinfo(String[] ids) throws ServiceException;
	
	/**
	 * 获取分页数据,只获取审核通过的新闻
	 * @author wanglei@enersun.con.cn
	 * @return PageResult
	 * @throws Exception
	 */
	public PageResult queryNewsinfoPublished(int pageNo, int pageSize, Newsinfo searchCondition) throws Exception;
	
	/**
	 * 获取分页数据,只获取审核通过的新闻
	 * @author wanglei@enersun.con.cn
	 * @return PageResult
	 * @throws Exception
	 */
	public PageResult queryNewsinfo(int pageNo, int pageSize, Newsinfo searchCondition) throws Exception;
	
	/**
	 * 通过solr查询 后台的新闻编剧栏目的查询
	 * @param pageNo
	 * @param pageSize
	 * @param searchCondition
	 * @return
	 * @throws Exception
	 */
	public PageResult queryNewsinfoSolr(int pageNo, int pageSize, Newsinfo searchCondition) throws Exception;
	
	/**
	 * 通过solr查询 首页的查询高亮
	 * @param pageNo
	 * @param pageSize
	 * @param searchCondition
	 * @return
	 * @throws Exception
	 */
	public PageResult queryNewsinfoSolrTwo(int pageNo, int pageSize, Newsinfo searchCondition) throws Exception;
	
	/**
	 * 根据新闻ID获取新闻信息，获取新闻详情信息
	 * @author wanglei@enersun.con.cn
	 * @createDate 2016-7-4 11:07:27
	 * @param id
	 * @return Newsinfo
	 */
	public Newsinfo getFullNewsinfoById(String id) throws Exception;
	
	/**
	 * 批量保存上传文件信息
	 * @author wanglei@enersun.con.cn
	 * @createDate 2016-7-4 14:09:25
	 * @return int（保存成功的数量）
	 * @throws Exception
	 */
	public int saveNewsdetailinfoBatch(List<Newsdetailinfo> list) throws Exception;
	
	public int updateSortsNewsdetailinfoBatch(List<Newsdetailinfo> list) throws Exception;
	
	/**
	 * 添加新闻信息
	 * @author wanglei@enersun.con.cn
	 * @createDate 2016-7-7 10:33:28
	 * @param newsinfo
	 * @param type
	 * @param request
	 * @return boolean
	 * @throws Exception
	 */
	public boolean addNewsInfo(Newsinfo newsinfo, String type, boolean isReview, HttpServletRequest request) throws Exception;
	
	/**
	 * @author wanglei@enersun.con.cn
	 * @createDate 2016-7-7 10:33:28
	 * @param isReview
	 * @param id
	 * @param newsinfoVO
	 * @return
	 * @throws Exception
	 */
	public boolean modifyNewsInfo(boolean isReview, String id, Newsinfo newsinfoVO, HttpServletRequest request) throws Exception;
	
	/**
	 * 获取图片新闻中的图片列表
	 * 	@author wanglei@enersun.con.cn
	 * @createDate 2016-7-7 11:03:41
	 * @param newsinfoId
	 * @param picTempPath
	 * @param request
	 * @return List<Newsdetailinfo>
	 * @throws Exception
	 */
	public List<Newsdetailinfo> listImage(String newsinfoId, String picTempPath, HttpServletRequest request) throws Exception;
	
	/**
	 * 获取图片新闻中的图片列表
	 * @param newsinfoId
	 * @return
	 * @throws Exception
	 */
	public List<Newsdetailinfo> listImage(String newsinfoId) throws Exception;
	
	/**
	 * 上传图片到图片新闻中，如果newsinfoId为空则为入库，图片会上传到临时文件夹下
	 * 	@author wanglei@enersun.con.cn
	 * @createDate 2016-7-7 11:05:22
	 * @param request
	 * @param newsinfoId
	 * @param picTempPath
	 * @return OutMessage
	 * @throws Exception
	 */
	public OutMessage uploadImageToPicNews(HttpServletRequest request, String newsinfoId, String picTempPath)  throws Exception;
	
	
	/**
	 *  在编辑时删除多余的图片信息
	 * 	@author wanglei@enersun.con.cn
	 * @createDate 2016-7-7 14:18:43
	 * @param request
	 * @param newContent
	 * @param oldContent
	 * @throws Exception
	 */
	public void deleteSurplusImageFromContentByReg(HttpServletRequest request, String newContent, String oldContent) throws Exception;
	
	/**
	 * 保存审核信息
	 * @param newsinfo
	 * @param isReview
	 * @return
	 * @throws Exception
	 */
	public boolean saveReview(Newsinfo newsinfo, boolean isReview) throws Exception;
	
	/**
	 * 通过ID查询新闻信息
	 * @param newsId
	 * @return Newsinfo
	 * @throws Exception
	 */
	public Newsinfo findNewsinfoById(String newsId) throws Exception;
	/**
	 * 首页轮播
	 * @param rows 条数
	 * @return
	 * @throws Exception
	 */
	public List<HashMap<String, Object>> listNewsinfo_carousel(int rows) throws Exception;

	/**
	 * 置顶新闻
	 * @param rows 条数
	 * @return
	 * @throws Exception
	 */
	public List<HashMap<String, Object>> listNewsinfo_top(int rows) throws Exception;
	/**
	 * 按主题查找新闻
	 * @param rows 行数
	 * @param columnId 主题ID
	 * @return
	 * @throws Exception
	 */
	public List<HashMap<String, Object>> listNewsinfo_columns(int rows, String columnId) throws Exception;
	/**
	 * 最新新闻
	 * @param rows 行数
	 * @return
	 * @throws Exception
	 */
	public List<HashMap<String, Object>> listNewsinfo_upToDate(int rows) throws Exception;
	
	/**
	 * 手机端登录
	 * @author wanglei@enersun.com.cn
	 * @param userName
	 * @param password
	 * @return OutMessage
	 * @throws Exception
	 */
	public OutMessage mobileLogin(String userName, String password) throws Exception;

	/**
	 * 获取最新发布的新闻
	 * @param  limit 限制的条数
	 * @return 新闻集合
	 * @throws Exception
	 * */
	public List<Newsinfo> getLatestPublishNews(int limit);

	/**
	 * 随机获取一条id不相等的图片新闻id
	 * @param  id 需要过滤的图片id
	 * @return 新闻id
	 * @throws Exception
	 * */
	public String getRandomNewsinfo(String id);

	/**
	 * 根据栏目id获取发布的新闻的数量
	 * @param  columnid 栏目的id
	 * @return 新闻的数量
	 * @throws Exception
	 * */
	public int getPublishNewsCountByColumnid(String columnid);
	

	/**
	 * 根据栏目id获取发布的新闻
	 * @param  pageNo 页码
	 * @param  limit 每页大小
	 * @param  columnid 栏目的id
	 * @return 新闻集合
	 * @throws Exception
	 * */
	public List<Newsinfo> getPublishNewsByColumnid(int pageNo, int limit, String columnid);
	/**
	 * 根据批量ID查询
	 * @param ids
	 * @return
	 */
	public List<Newsinfo> getNewsInIds(String[] ids, boolean isNull);
	/**
	 * 专题ID查询新闻
	 * @param snId
	 * @return
	 */
	public List<Newsinfo> getNewsBySNID(String snId);
	
	public PageResult queryNewsIsNotSpecial(int pageNo, int pageSize, Newsinfo searchCondition) throws Exception;

	public List<HashMap<String, Object>> getSpecialNewsUpToDate(int rows) ;

	public List<Specialnews> getSpecialNews();
}
